//主模块
import {IStoreState} from '@/types'

//state
export const state = function():IStoreState{
  return {
    bNav: false,
    bLoading: false
  }
};

//mutations
export const mutations = {
  M_UPDATE_NAV(state:IStoreState, payload:boolean) {
    state.bNav = payload;
  },
  M_UPDATE_LOADING(state:IStoreState, payload:boolean) {
    state.bLoading = payload;
  }
}

//actions
export const actions = {
  nuxtServerInit(store:any, context:any) {
    //初始化token东西到store当中  
    let user = context.app.$cookies.get('user') ? context.app.$cookies.get('user') : {err:2,msg:'未登录',token:''};
    store.commit('user/M_UPDATE_USER',user)
  }
}

//getters
export const getters = {
  getNav(state:IStoreState){
    return state.bNav ? '显示' : '隐藏'
  }
}